using System;

namespace Examples.UnitTestATM
{
    public class Money
    {
        private readonly int _amount;

        public Money(int amount)
        {
            _amount = amount;
        }

        public static Money operator -(Money left, Money right)
        {
            return new Money(left._amount - right._amount);
        }

        public static bool operator  < (Money left, int right)
        {
            return left._amount < right;
        }

        public static bool operator <=(Money left, int right)
        {
            return left._amount <= right;
        }

        public static bool operator >=(Money left, int right)
        {
            return left._amount >= right;
        }

        public static bool operator >(Money left, int right)
        {
            return left._amount > right;
        }

        public static bool operator <(Money left, Money right)
        {
            return left._amount < right._amount;
        }

        public static bool operator >(Money left, Money right)
        {
            return left._amount > right._amount;
        }

        public override string ToString()
        {
            return "$" + _amount;
        }

        public bool Equals(Money other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._amount == _amount;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Money)) return false;
            return Equals((Money) obj);
        }

        public override int GetHashCode()
        {
            return _amount;
        }
    }
}